var express = require('express');
var router = express.Router();
var uuid = require('uuid').v1;


// 获取全部api接口数据 
// 刷新列表
router.get('/getRenderData', function (req, res, next) {
    var projectId = req.query.projectId;
    var foldersSql = `SELECT * FROM folder WHERE folder_project_id=? AND disable = 0 and type = 0`;
    var apiSql = `SELECT * FROM project_api WHERE project_id=? AND disable = 0`;
    query(foldersSql, [projectId], function (qerr, vals, fields) {
        if (qerr) {
            res.status(500);
            res.json({
                msg: qerr
            });
        } else {
            var folders = vals;
            query(apiSql, [projectId], function (qerr, vals, fields) {
                if (qerr) {
                    res.status(500);
                    res.json({
                        msg: qerr
                    });
                } else {
                    res.json({
                        folders: folders,
                        apis: vals
                    });
                };
            });
        };
    });
})












module.exports = router;